package com.chen.controller;

import com.chen.service.SystemService;
import com.chen.vo.Result;
import com.chen.vo.param.AlbumParam;
import com.chen.vo.param.CardParam;
import com.chen.vo.param.FirstPageParam;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Author:chenao
 * @DATE:2022/3/2 17:14
 */
@RestController
@RequestMapping("system")
public class SystemController {

    @Autowired
    private SystemService systemService;


    /**
     * 首页配置系统返回列表展示
     * @param firstPageParam
     * @return
     */
    @PostMapping("first")
    public Result listSwiper(@RequestBody FirstPageParam firstPageParam) {
        return systemService.listSetting(firstPageParam);
    }

    /**
     * 首页添加(修改)轮播图配置
     * @param file
     * @param params
     * @return
     */
    @PostMapping("swipersave")
    public Result addSwiperSetting(@RequestParam("file") MultipartFile file,@RequestParam Map<String,String> params) {
        return systemService.addSwiperSetting(file,params);
    }

    /**
     * 轮播图删除
     * @param firstPageParam
     * @return
     */
    @PostMapping("swiper/delete")
    public Result deleteSwiperSetting(@RequestBody FirstPageParam firstPageParam) {
        return systemService.deleteSettingById(firstPageParam.getId());
    }


    /**
     * 添加(修改)会员卡配置
     * @param file
     * @param params
     * @return
     */
    @PostMapping("cardsave")
    public Result addCardSetting(@RequestParam("file") MultipartFile file,@RequestParam Map<String,String> params){
        return systemService.addCardSetting(file,params);
    }

    /**
     * 会员卡列表展示数据
     * @param param
     * @return
     */
    @PostMapping("cardlist")
    public Result listCard(@RequestBody CardParam param){
        return systemService.listCard(param);
    }

    /**
     * 删除某一个会员卡配置
     * @param param
     * @return
     */
    @PostMapping("card/delete")
    public Result deleteCard(@RequestBody CardParam param){
        return systemService.deleteCardById(param.getId());
    }

    /**
     * 添加店铺相册
     * @param file
     * @param params
     * @return
     */
    @PostMapping("album/save")
    public Result addAlbum(@RequestParam("file") MultipartFile file,@RequestParam Map<String,String> params){
        return systemService.addAlbum(file,params);
    }

    /**
     * 相册展示列表
     * @param param
     * @return
     */
    @PostMapping("album/list")
    public Result listAlbum(@RequestBody AlbumParam param){
        return systemService.listAlbum(param);
    }

    @PostMapping("album/delete")
    public Result deleteAlbum(@RequestBody AlbumParam param){
        return systemService.deleteAlbumById(param.getId());
    }


}
